<%--
  Created by IntelliJ IDEA.
  User: 86166
  Date: 2024/08/17
  Time: 20:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>融资管理系统</title>
    <%
        String base = request.getContextPath() + "/";
        String url = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + base;
    %>
    <base href="<%=url%>">
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        //凭证融资基本信息
        $(document).ready(function () {
            // var voucher_id = $("[name='hitxt']").val();
            var voucher_id = '<%=request.getParameter("id")%>';
            $.get("systerm/ticketDetail", {"voucher_id": voucher_id}, function (ticket) {
                JSON.stringify(ticket);
                console.log(ticket);
                //开单企业
                $("#open_enterpriseName").empty();
                $("<tr>" +
                    "<td>" + ticket.open_enterprise_name + "</td>" +
                    "</tr>").appendTo("[id='open_enterpriseName']");
                //开单企业的社会信用代码
                $("#social_uniform_code").empty();
                $("<tr>" +
                    "<td>" + ticket.open_social_uniform_code + "</td>" +
                    "</tr>").appendTo("[id='social_uniform_code']");
                //金融机构名称
                $("#institutyName").empty();
                $("<tr>" +
                    "<td>" + ticket.instituty_name + "</td>" +
                    "</tr>").appendTo("[id='institutyName']");

                //凭证金额
                $("#amount").empty();
                $("<tr>" +
                    "<td>" + ticket.amount + "</td>" +
                    "</tr>").appendTo("[id='amount']");
                //开单时间
                $("#open_time").empty();
                $("<tr>" +
                    "<td>" + ticket.open_time + "</td>" +
                    "</tr>").appendTo("[id='open_time']");

                //计算天数间隔
                var now=new Date();
                var eDate = Date.parse(ticket.expiry_time)
                var days = Math.ceil((eDate - now) / (24 * 60 * 60 * 1000))
                //到期时间
                $("#expiry_time").empty();
                $("<tr>" +
                    "<td>" + ticket.expiry_time +"<span style='font-size: 12px;color: #999'>剩余"+days+"天</span>"+ "</td>" +
                "</tr>").appendTo("[id='expiry_time']");
                //付息方式
                $("#payment_interest_type").empty();
                $("<tr>" +
                    "<td>" + ticket.payment_interest_type + "</td>" +
                    "</tr>").appendTo("[id='payment_interest_type']");
                //备注
                $("#remark").empty();
                $("<tr>" +
                    "<td>" + ticket.remark + "</td>" +
                    "</tr>").appendTo("[id='remark']");
            });
        });


        //第二个界面第二个功能
        $(document).ready(function () {
            $("#btnTrans").click(function () {
                $("#input-name").val($("#amount").text());
                changeLastMoney();
            });

            $("#input-name").blur(function () {
                changeLastMoney();
                if (parseFloat($("#input-name").val()) > parseFloat($("#amount").text())){
                    $("#input-name").val(0);
                    changeLastMoney();
                    alert("融资金额" + parseFloat($("#input-name").val()) + "超过凭证金额" + parseFloat($("#amount").text()) + "，请重新输入");
                }
            });
            $("#submitBtn").on("click", function () {
                var id = $("[name='hitxt']").val();
                remark = $("#user-intro").val();
                amount = parseFloat($("#input-name").val());
                //alert("id："+id+"amount："+amount+"voucher_amount："+voucher_amount+"cost："+cost+"receipt_amount："+receipt_amount+"instituty_id："+instituty_id+"receipt_day："+receipt_day+"uplink_address："+uplink_address+"remark："+remark);
                $.get("financing/insertFinancing", {
                    "id":id,
                    "amount":amount,
                    "voucher_amount":voucher_amount,
                    "cost":cost,
                    "receipt_amount":receipt_amount,
                    "instituty_id":instituty_id,
                    "receipt_day":receipt_day,
                    "uplink_address":uplink_address,
                    "payment_interest_type":payment_interest_type,
                    "remark":remark,
                    "open_enterprise_id":open_enterprise_id,
                    "expiry_time":expiry_time,
                    "source":source,
                    "payment_interest_type":payment_interest_type
                });
            });
        });
        function changeLastMoney() {
            $("#last-money").text(parseFloat($("#amount").text()) - parseFloat($("#input-name").val()));
        }
        //融资第三模块
            $(document).ready(function () {
                var bid = $("[name='hitxt']").val();
                $.get("systerm/querymyticketfinancing1", {"bi": bid}, function (institutyDetail) {
                    JSON.stringify(institutyDetail);

                    function appendRowsToTable(data, tableId) {
                        var $table = $(tableId);
                        $table.empty(); // 清空表格
                        for (var i = 0; i < data.length; i++) {
                            $("<tr>" +
                                "<td>" + data[i].instituty_id + "</td>" +
                                "<td>" + data[i].receipt_amount + "</td>" +
                                "<td>" + data[i].cost + "</td>" +
                                "<td>" + data[i].interest + "</td>" +
                                "<td>" + data[i].receipt_day + "</td>" +
                                "</tr>").appendTo($table);
                        }
                    }

                    // 向不同的表格追加数据
                    appendRowsToTable(institutyDetail, "#a");
                    appendRowsToTable(institutyDetail, "#b");
                    appendRowsToTable(institutyDetail, "#c");
                    appendRowsToTable(institutyDetail, "#d");
                });
            });


    </script>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/app.css">
    <style>
        .star::before {
            content: '*';
            color: #F56C6C;
            margin-right: 0.020833rem;
        }

        .am-selected {
            width: 100%
        }

        .am-selected-status {
            font-size: 13px;
            color: #999;
        }
    </style>
</head>
<body data-type="generalComponents">
<header class="am-topbar am-topbar-inverse admin-header">
    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">
        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">
            <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
                <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
                    <span class="tpl-header-list-user-nick">禁言小张</span><span class="tpl-header-list-user-ico"> <img
                        src="assets/img/user01.png"></span>
                </a>
                <ul class="am-dropdown-content">
                    <li><a href="login.jsp"><span class="am-icon-power-off"></span> 退出</a></li>
                </ul>
            </li>
        </ul>
    </div>
</header>
<div class="tpl-page-container tpl-page-header-fixed">
    <div class="tpl-left-nav tpl-left-nav-hover">
        <div class="tpl-left-nav-list">
            <ul class="tpl-left-nav-menu">
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list active">
                        <i class="am-icon-table"></i>
                        <span>凭证管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right tpl-left-nav-more-ico-rotate"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu" style="display:block">
                        <li>
                            <a href="finance-list.jsp">
                                <i class="am-icon-angle-right"></i>
                                <span>融资列表</span>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list">
                        <i class="am-icon-wpforms"></i>
                        <span>我的凭证</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="my-ticket-list.jsp">
                                <i class="am-icon-angle-right"></i>
                                <span>我的凭证列表</span>
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <div class="tpl-content-wrapper">
        <div class="tpl-content-page-title">
            凭证融资
        </div>
        <ol class="am-breadcrumb">
            <li class="am-active"><a style="color: #999999;">凭证管理</a></li>
            <li class="am-active">凭证融资</li>
        </ol>
        <!-- 基本信息 -->
        <div class="tpl-portlet-components" id="baseinfoDiv">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    凭证基本信息
                </div>
                <div class="tpl-portlet-input tpl-fz-ml">
                    <div class="portlet-input input-small input-inline">
                        <div class="input-icon right">
                        </div>
                    </div>
                </div>
            </div>
            <div class="tpl-block ">
                <div class="am-g tpl-amazeui-form">
                    <div class="am-u-sm-12 am-u-md-6">
                        <form class="am-form am-form-horizontal">
                            <div  class="am-form-group">
                                <%--@declare id="user-name"--%><label for="user-name" class="am-u-sm-3 am-form-label">开单企业</label>
                                <div id="open_enterpriseName"  class="am-u-sm-9" style="margin-top: 4px;font-size: 16px;">
                                    百度科技有限公司
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">统一社会信用代码</label>
                                <div class="am-u-sm-9" style="margin-top: 4px;font-size: 16px;">
                                    91110000802100BBBB
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">金融机构</label>
                                <div id="institutyName" class="am-u-sm-9" style="margin-top: 4px;font-size: 16px;">
                                    中国工商银行
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">凭证金额</label>
                                <div id="amount" class="am-u-sm-9" style="font-size: 19px;color: red;font-weight: 500;">
                                    10,000,000.00元
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">开单日期</label>
                                <div id="open_time" class="am-u-sm-9" style="margin-top: 4px;font-size: 16px;">
                                    2021-03-28
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">到期日期</label>
                                <div id="expiry_time" class="am-u-sm-9" style="margin-top: 4px;font-size: 16px;">
                                    2021-04-28 <span style="font-size: 12px;color: #999">剩余 10 天</span>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">付息方式</label>
                                <div id="payment_interest_type" class="am-u-sm-9" style="margin-top: 4px;font-size: 16px;">
                                    融资企业付息
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">备注</label>
                                <div id="remark" class="am-u-sm-9" style="margin-top: 4px;font-size: 16px;">
                                    备注信息备注信息备注信息备注信息备注信息备注信息备注信息
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-u-sm-12 am-u-md-6">
                    </div>
                </div>
            </div>
        </div>
        <div class="tpl-portlet-components" id="showDiv">
            <!-- 表单填写页面 -->
            <div class="tpl-block">
                <div class="">
                    <div class="portlet-title">
                        <div class="caption font-green bold">
                            融资业务信息
                        </div>
                        <div class="tpl-portlet-input tpl-fz-ml">
                            <div class="portlet-input input-small input-inline">
                                <div class="input-icon right">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="tpl-block ">
                        <div class="am-g tpl-amazeui-form">
                            <div class="am-u-sm-12 am-u-md-6">
                                <form class="am-form am-form-horizontal">
                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label star"> 融资金额</label>
                                        <div class="am-u-sm-9" style="margin-top: 4px;font-size: 16px;">
                                            <input value="" type="text" id="input-name" placeholder="请输入凭证金额">
                                            <span id="btnTrans"
                                                  style="color:#3bb4f2;font-size:12px;cursor: pointer;">全部融资</span>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="am-u-sm-12 am-u-md-6">
                                <form class="am-form am-form-horizontal">
                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">剩余凭证金额</label>
                                        <div class="am-u-sm-9" id="last-money" style="margin-top: 4px;font-size: 16px;">
                                            10,000,000,000.00元
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="am-g tpl-amazeui-form">
                            <div class="am-u-sm-12 am-u-md-6">
                                <form class="am-form am-form-horizontal">
                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">备注</label>
                                        <div class="am-u-sm-9" style="margin-top: 4px;font-size: 16px;">
                                                <textarea class="" rows="4" id="user-intro"
                                                          placeholder="请输入备注"></textarea>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="tpl-portlet-components">
            <!-- 金融机构信息 -->
            <div class="tpl-block" id="institutionDiv">
                <div class="">
                    <div class="portlet-title">
                        <div class="caption font-green bold">
                            金融机构信息
                        </div>
                        <div class="tpl-portlet-input tpl-fz-ml">
                            <div class="portlet-input input-small input-inline">
                                <div class="input-icon right">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="tpl-block ">
                        <div class="am-g">
                            <div class="am-u-sm-12">
                                <form class="am-form">
                                    <table class="am-table am-table-striped am-table-hover table-main">
                                        <tbody id="doc-modal-list">
                                        <tr data-id="2">
                                            <td>
                                                <label class="am-radio">
                                                    <input type="radio" name="radio1" value="" data-am-ucheck
                                                           checked>
                                                </label>
                                            </td>
                                            <td class="am-hide-sm-only" style="line-height: 54px">中国工商银行</td>
                                            <td class="am-hide-sm-only">
                                                <div>预计到账</div>
                                                <div style="font-size: 20px;font-weight: bold;">¥
                                                    1,000,000,000.00
                                                </div>
                                            </td>
                                            <td class="am-hide-sm-only">
                                                <div>融资成本 （利率约 6%）</div>
                                                <div style="font-size: 20px;font-weight: bold;"> ¥ 60,000,000.00
                                                </div>
                                            </td>
                                            <td class="am-hide-sm-only" style="line-height: 54px">预计 3 天到账</td>
                                        </tr>

                                        <tr data-id="2">
                                            <td><label class="am-radio">
                                                <input type="radio" name="radio1" value="" data-am-ucheck>
                                            </label></td>
                                            <td class="am-hide-sm-only" style="line-height: 54px">中国工商银行</td>
                                            <td class="am-hide-sm-only">
                                                <div>预计到账</div>
                                                <div style="font-size: 20px;font-weight: bold;">¥
                                                    1,000,000,000.00
                                                </div>
                                            </td>
                                            <td class="am-hide-sm-only">
                                                <div>融资成本 （利率约 6%）</div>
                                                <div style="font-size: 20px;font-weight: bold;"> ¥ 60,000,000.00
                                                </div>
                                            </td>
                                            <td class="am-hide-sm-only" style="line-height: 54px">预计 3 天到账</td>
                                        </tr>
                                        <tr data-id="2">
                                            <td><label class="am-radio">
                                                <input type="radio" name="radio1" value="" data-am-ucheck>
                                            </label></td>
                                            <td class="am-hide-sm-only" style="line-height: 54px">中国工商银行</td>
                                            <td class="am-hide-sm-only">
                                                <div>预计到账</div>
                                                <div style="font-size: 20px;font-weight: bold;">¥
                                                    1,000,000,000.00
                                                </div>
                                            </td>
                                            <td class="am-hide-sm-only">
                                                <div>融资成本 （利率约 6%）</div>
                                                <div style="font-size: 20px;font-weight: bold;"> ¥ 60,000,000.00
                                                </div>
                                            </td>
                                            <td class="am-hide-sm-only" style="line-height: 54px">预计 3 天到账</td>
                                        </tr>
                                        <tr data-id="2">
                                            <td><label class="am-radio">
                                                <input type="radio" name="radio1" value="" data-am-ucheck>
                                            </label></td>
                                            <td class="am-hide-sm-only" style="line-height: 54px">中国工商银行</td>
                                            <td class="am-hide-sm-only">
                                                <div>预计到账</div>
                                                <div style="font-size: 20px;font-weight: bold;">¥
                                                    1,000,000,000.00
                                                </div>
                                            </td>
                                            <td class="am-hide-sm-only">
                                                <div>融资成本 （利率约 6%）</div>
                                                <div style="font-size: 20px;font-weight: bold;"> ¥ 60,000,000.00
                                                </div>
                                            </td>
                                            <td class="am-hide-sm-only" style="line-height: 54px">预计 3 天到账</td>
                                        </tr>
                                        <tr data-id="2">
                                            <td><label class="am-radio">
                                                <input type="radio" name="radio1" value="" data-am-ucheck>
                                            </label></td>
                                            <td class="am-hide-sm-only" style="line-height: 54px">中国工商银行</td>
                                            <td class="am-hide-sm-only">
                                                <div>预计到账</div>
                                                <div style="font-size: 20px;font-weight: bold;">¥
                                                    1,000,000,000.00
                                                </div>
                                            </td>
                                            <td class="am-hide-sm-only">
                                                <div>融资成本 （利率约 6%）</div>
                                                <div style="font-size: 20px;font-weight: bold;"> ¥ 60,000,000.00
                                                </div>
                                            </td>
                                            <td class="am-hide-sm-only" style="line-height: 54px">预计 3 天到账</td>
                                        </tr>
                                        </tbody>
                                    </table>

                                    <hr>

                                </form>
                            </div>
                        </div>
                        <div style="text-align: center;margin-top:40px">
                            <a class="am-btn am-btn-default" href="my-ticket-list.jsp">取&nbsp;&nbsp;&nbsp;&nbsp;
                                消</a>
                            <a id="submitBtn" class="am-btn am-btn-primary"
                               style="margin-left:20px">提&nbsp;&nbsp;&nbsp;&nbsp; 交</a>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 提交成功页面 -->
            <div class="tpl-block " id="resultDiv" hidden>
                <div class="am-g tpl-amazeui-form">
                    <div class="am-u-sm-12 am-u-md-12">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <div class="am-u-sm-12"
                                     style="margin-top: 4px;text-align: center;margin-bottom: 20px;">
                                    <img src="assets/img/u105.png" alt="" style="width: 120px;">
                                </div>
                                <div class="am-u-sm-12"
                                     style="margin-top: 4px;font-size: 20px;text-align: center;font-weight: bold;margin-bottom: 20px;">
                                    提交申请成功
                                </div>
                                <div class="am-u-sm-12" style="color: #999;font-size:14px;text-align: center;">
                                    已通知审核人员尽快审核，最终结果将以站内信的方式告知您。
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <div style="text-align: center;margin-top:40px">
                    <a class="am-btn am-btn-primary" href="my-ticket-list.jsp">返回列表</a>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="assets/js/jquery.min.js">
</script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
<script>
    // 提交按钮
    $(function () {
        $('#submitBtn').on('click', function () {
            $('#baseinfoDiv').hide();
            $('#showDiv').hide();
            $('#institutionDiv').hide();
            $('#resultDiv').show();
        });
    });
    // 全部转让按钮
    $(function () {
        $('#btnTrans').on('click', function () {
            $('#input-name').val('10,000,000.00');
        });
    });
</script>
</body>

</html>